package class5;

import java.io.File;

public class demo3 {
    public static void main(String[] args) {
        String path="D:"+File.separator+"C++";
        File file=new File(path);
        if(file.exists()&& file.isDirectory()){
            kakan(file);
        }
        System.err.println("路径无效："+path);
    }

    static void kakan(File file){
        File []list=file.listFiles();
        if (list==null){
            System.err.println("无法访问目录："+file.getAbsolutePath());
            return;
        }

        for (int i = 0; i < list.length ; i++) {
            if(list[i].isDirectory()){
                kakan(list[i]);
            }
            else {
                System.out.println(list[i].getAbsolutePath());
            }
        }
    }

}
